<template>
        <!-- 技术交底编辑 -->
        <a-spin :spinning="loading">
            <a-form-model
                    ref="ruleForm"
                    :model="form"
                    :label-col="{ span: 6 }"
                    :wrapper-col="{ span: 18 }"
            >
                <!-- 表格 -->
                <a-card :bordered="false" v-for="form in dataList" :key="form.id">
<!--                    <title-name title="基本信息"></title-name>-->
                    <custom-form
                            :formList="formList"
                            :form="form"
                            :editModel="editModel == 0 ? '' : ''"
                            @getOption="getOption"
                            :isEmit="false"
                    >
                        <!-- 附件上传 -->
                        <template #fileInfoVOSigns>
                            <template v-if="editModel != 0">
                                <l-table businessCode="FACE01" :uploadArrys.sync="form.fileInfoVOSigns"></l-table>
                                <!-- <div class="file_prompt">支持扩展名：.rar .zip .doc .docx .pdf .jpg...</div> -->
                            </template>
                            <file-link v-else :file-list="form.fileInfoVOSigns" style="margin-top: -3px"></file-link>
                        </template>
                        <template #fileInfoVOPictures>
                            <template v-if="editModel != 0">
                                <upload-list
                                        :businessCode="'FACE01'"
                                        uploadType="image"
                                        :editModel="editModel"
                                        :uploadArrys.sync="form.fileInfoVOPictures"
                                        multiple
                                ></upload-list>
                            </template>
                            <template v-else>
                                <span v-if="!form.fileInfoVOPictures || form.fileInfoVOPictures.length < 1">
                                    <empty description="`暂未上传照片`"></empty>
                                </span>
                                <upload-list
                                        v-else
                                        :businessCode="'FACE01'"
                                        uploadType="image"
                                        :editModel="editModel"
                                        :uploadArrys.sync="form.fileInfoVOPictures"
                                        multiple
                                ></upload-list>
                            </template>
                        </template>
                    </custom-form>
                </a-card>
            </a-form-model>
             </a-spin>
</template>

<script>
  import {
    getTechnicalDisclosureById,
    queryTechnicalDisclosureList
  } from '@/api/technical/technicalClarificaiton'
  import BaseEditPage from '@/views/baseEditPage' // 编辑详情页基础配置
  import SelectSubcontractor from '@/components/Select/SelectSubcontractor' // 分包商
  import SelectPersonByProject from '@/components/Select/SelectPersonByProject'
  import { getProjectTypes} from '@/api/project/projects'
  import UploadList from '@/components/UploadList'
  import SelectTreeSubItem from '@/components/Select/SelectTreeSubItem' // 分部分项
  import ASelectOrgPeople from '@/components/Select/ASelectOrgPeople'
  import { getList} from '@/api/technical/approval'
  import { Empty } from 'ant-design-vue'
  export default {
    name: 'a' + Date.now(),
    extends: new BaseEditPage(),
    components: {
      UploadList,
      Empty,
    },
    data() {
      return {
        loading: false, // 加载控件
        visible: false, //人员选择控件
        editModel: 0, // 操作状态:0 查看;1 编辑;2 新增
        id: '',
        subContractorOrgId: '', //分包商组织id
        loadingBtn: {
          DELETE: false,
          DRAFT: false,
          SUBMITTED: false,
          REJECTED: false
        },
        init: false, // 初始化控件
        qualityTypes:[],
        SelectOrgId:null,   //单位id
        programList:[], //方案名称
        dataList: [{fileInfoVOSigns: [], fileInfoVOPictures: []}]
      }
    },
    mounted() {
      this.loading = true
      queryTechnicalDisclosureList({ ids: [this.$route.query.technologyStatusId]})
        .then((res) => {
          this.loading = false
          const versionNum = this.$route.query.versionNumber
          this.dataList = res.data.filter(item => item.version == versionNum)
        })
        .catch(() => {
          this.loading = false
        })
      this.getProjectTypes();
    },
    computed: {
      formList() {
        return [
          {
            keyName: 'floorName',
            type: 'BaseInput',
            disabled: this.editModel == 0,
            label: '工程部位'
          },
          {
            keyName: 'projectType',
            type: 'a-select',
            data: this.qualityTypes,
            disabled: this.editModel == 0,
            label: '工程类别'
          },
          {
            keyName: 'subItemProjectName',
            type: 'BaseInput',
            disabled: this.editModel == 0,
            label: '分部分项',
          },
          {
            keyName: 'programmeName',
            type: 'BaseInput',
            disabled: this.editModel == 0,
            label: '方案名称',
          },
          {
            keyName: 'quantities',
            type: 'BaseInput',
            disabled: this.editModel == 0,
            precision: 2,
            label: '工程量'
          },

          {
            type: 'BaseInput',
            keyName: 'subcontractorName',
            label: '分包单位',
            disabled: this.editModel == 0
          },
          {
            label: '分包负责人',
            keyName: 'subcontractorLeaderName',
            type: 'BaseInput',
            disabled: this.editModel == 0
          },
          {
            keyName: 'disclosureTime',
            type: 'a-date-picker',
            disabled: this.editModel == 0,
            label: '交底时间',
            attrs: {
              valueFormat: 'YYYY-MM-DD'
            }
          },
          {
            keyName: 'disclosureUserId',
            type: ASelectOrgPeople,
            disabled: this.editModel == 0,
            label: '交底人',
            attrs: {
              orgId: this.SelectOrgId,
              init:false,
              isCreatorName:true
            },

          },
          {
            keyName: 'disclosureContent',
            type: 'BaseTextarea',
            label: '交底内容简述',
            disabled: this.editModel == 0,
            span: 24
          },

          {
            slot: true,
            keyName: 'fileInfoVOSigns',
            label: '交底原件',
            span: 24
          },
          {
            slot: true,
            keyName: 'fileInfoVOPictures',
            label: '会议照片',
            span: 24
          }
        ]
      }
    },
    methods: {
      getProgrammeName(val){
        let findData = this.programList.find((item)=>item.id == val);
      },
      //获取工程类别
      getProjectTypes() {
        getProjectTypes().then((res) => {
          this.qualityTypes = res.data?.filter(i => i.status*1 === 1)
          if(this.qualityTypes && this.qualityTypes.length>0){
            this.qualityTypes.map((item)=>{
              item.label = item.projectTypeName;
              item.value = item.projectTypeId
            })
          }
        })
      },
      /**
       * 输入框事件
       */
      getOption(e, data) {
        if (e == 'subcontractorId') {
          this.subContractorOrgId = data?.subContractorOrgId
        }
      },
    }
  }
</script>

<style lang="less" scoped>
    /deep/.ant-input {
        border-color: #e4ac0b;
        background-color: #fff9e8;
    }
    /deep/.ant-input-disabled
    {
        border-color: #d9d9d9 !important;
        background-color: #f5f5f5 !important;
    }

    /deep/ .ant-form-item {
        .ant-form-item-label {
            height: 28px;
            width: 200px;
            line-height: 22px;
            padding: 6px 4px 0 0;
            text-align: right;
            white-space: pre-wrap;
            overflow: visible;
        }
        .ant-form-item-control-wrapper {
            width: calc(100% - 200px);
        }
    }
    .file_prompt {
        color: #999;
    }
</style>
